//
//  UIAlertController+Tool.m
//  SLDemo
//
//  Created by bocai on 2016/12/20.
//  Copyright © 2016年 Heracles. All rights reserved.
//

#import "UIAlertController+Tool.h"

@implementation UIAlertController (Tool)

+ (UIAlertController *)t_alertControllerWithTitle:(NSString *)title
                                          message:(NSString *)message
                                        sureTitle:(NSString *)sureTitle
                                      cancelTitle:(NSString *)cancelTitle
                                      sureHandler:(void (^)(UIAlertAction *action))sureHandler
{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    
    if (sureTitle && sureHandler) {
        UIAlertAction *action = [UIAlertAction actionWithTitle:sureTitle style:UIAlertActionStyleDefault handler:sureHandler];
        [alertController addAction:action];
    }
    
    if (cancelTitle) {
        UIAlertAction *action = [UIAlertAction actionWithTitle:cancelTitle style:UIAlertActionStyleCancel handler:nil];
        [alertController addAction:action];
    }
    
    return alertController;
}

+ (UIAlertController *)t_alertControllerWithTitle:(NSString *)title
                                          message:(NSString *)message
                                      cancelTitle:(NSString *)cancelTitle
{
    return [UIAlertController t_alertControllerWithTitle:title message:message sureTitle:nil cancelTitle:cancelTitle sureHandler:nil];
}

@end
